package com.xayy.mgt.controller;

import cn.kawins.base.basic.IBasicEndpoint;
import cn.kawins.base.result.ResultBody;
import com.xayy.core.constant.BayesArgs;
import com.xayy.mgt.model.vo.DataInfoVo;
import com.xayy.mgt.service.BayesService;
import com.xayy.mgt.service.NodeInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 贝叶斯评估相关
 *
 * @author Nie
 * @version V1.0
 * @date 2023/9/14 9:40
 */
@RestController
@RequestMapping(value = "/bayes1")
@Api(tags = "贝叶斯评估相关")
public class BayesController implements IBasicEndpoint {

    @Autowired
    private NodeInfoService nodeInfoService;

    @Autowired
    private BayesService bayesService;

    @Autowired
    private BayesArgs bayesArgs;

    @GetMapping("/getLeftTree")
    @ApiOperation(value = "左侧树结构", httpMethod = "GET")
    public ResultBody bayesLeftTree() {

        return nodeInfoService.bayesLeftTree(bayesArgs.getNodeId(),bayesArgs.getNodeCode()).body();
    }


    @PostMapping("/getErrorDataInfos")
    @ApiOperation(value = "获取训练采样故障数据", httpMethod = "POST")
    public ResultBody getErrorDataInfos(@RequestBody DataInfoVo dataInfoVo) {
        return bayesService.getErrorDataInfos(dataInfoVo).body();
    }

    @PostMapping("/getDataInfos")
    @ApiOperation(value = "获取训练采样正常数据", httpMethod = "POST")
    public ResultBody getDataInfos(@RequestBody DataInfoVo dataInfoVo) {
        return bayesService.getDataInfos(dataInfoVo).body();
    }

    @PostMapping("/computeHealth")
    @ApiOperation(value = "计算节点健康度", httpMethod = "POST")
    public ResultBody computeHealth(@RequestBody DataInfoVo dataInfoVo) {
        return bayesService.computeHealth(dataInfoVo).body();
    }


}
